<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li :class="{ completed: item.isDone }" v-for="(item,index) in showArr" :key="item.id">
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.isDone" @click="$store.commit('smallShow',index)"/>
        <label>{{ item.name }}</label>
        <button class="destroy" @click="delTaskFn(item)"></button>
      </div>
    </li>
  </ul>
</template>

<script>
import { mapState, mapMutations,mapGetters } from "vuex";
export default {
  computed: {
    ...mapState(["list"]),
    ...mapGetters(['showArr']),
  },
  methods: {
    ...mapMutations(["delTask"]),
    delTaskFn(item) {
      this.delTask(item.id);
    },
  },
};
</script>
